/*   1:    */ package org.intellij.plugins.relaxNG.compact.parser;
/*   2:    */ 
/*   3:    */

import com.intellij.lang.PsiBuilder;
import com.intellij.lang.PsiBuilder.Marker;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import org.intellij.plugins.relaxNG.compact.RncElementTypes;
import org.intellij.plugins.relaxNG.compact.RncTokenTypes;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */ 
/*  10:    */ public abstract class AbstractParsing
/*  11:    */ {
/*  12: 32 */   protected static final TokenSet LA_INCLUDE_CONTENT = TokenSet.orSet(new TokenSet[] { TokenSet.create(new IElementType[] { RncTokenTypes.KEYWORD_DIV, RncTokenTypes.KEYWORD_START }), RncTokenTypes.IDENTIFIERS });
/*  13: 35 */   protected static final TokenSet LA_GRAMMAR_CONTENT = TokenSet.orSet(new TokenSet[] { TokenSet.create(new IElementType[] { RncTokenTypes.KEYWORD_INCLUDE }), LA_INCLUDE_CONTENT });
/*  14: 38 */   protected static final TokenSet ATTR_OR_ELEMENT = TokenSet.create(new IElementType[] { RncTokenTypes.KEYWORD_ATTRIBUTE, RncTokenTypes.KEYWORD_ElEMENT });
/*  15: 41 */   protected static final TokenSet CONTENT = TokenSet.create(new IElementType[] { RncTokenTypes.KEYWORD_LIST, RncTokenTypes.KEYWORD_MIXED });
/*  16: 44 */   protected static final TokenSet LA_DATATYPE = TokenSet.create(new IElementType[] { RncTokenTypes.KEYWORD_STRING, RncTokenTypes.KEYWORD_TOKEN });
/*  17: 47 */   protected static final TokenSet LA_DECL = TokenSet.create(new IElementType[] { RncTokenTypes.KEYWORD_DATATYPES, RncTokenTypes.KEYWORD_NAMESPACE, RncTokenTypes.KEYWORD_DEFAULT });
/*  18: 50 */   protected static final TokenSet NS_URI_LITERAL = TokenSet.create(new IElementType[] { RncTokenTypes.KEYWORD_INHERIT, RncTokenTypes.LITERAL });
/*  19: 51 */   protected static final TokenSet ASSIGN_METHOD = TokenSet.create(new IElementType[] { RncTokenTypes.EQ, RncTokenTypes.CHOICE_EQ, RncTokenTypes.INTERLEAVE_EQ });
/*  20:    */   protected final PsiBuilder myBuilder;
/*  21:    */   
/*  22:    */   public AbstractParsing(PsiBuilder paramPsiBuilder)
/*  23:    */   {
/*  24: 55 */     this.myBuilder = paramPsiBuilder;
/*  25:    */   }
/*  26:    */   
/*  27:    */   protected final PsiBuilder.Marker begin()
/*  28:    */   {
/*  29: 59 */     PsiBuilder.Marker localMarker = this.myBuilder.mark();
/*  30: 60 */     advance();
/*  31: 61 */     return localMarker;
/*  32:    */   }
/*  33:    */   
/*  34:    */   protected final boolean matches(TokenSet paramTokenSet)
/*  35:    */   {
/*  36: 65 */     if (paramTokenSet.contains(currentToken()))
/*  37:    */     {
/*  38: 66 */       advance();
/*  39: 67 */       return true;
/*  40:    */     }
/*  41: 69 */     return false;
/*  42:    */   }
/*  43:    */   
/*  44:    */   protected final boolean matches(IElementType paramIElementType)
/*  45:    */   {
/*  46: 73 */     if (paramIElementType == currentToken())
/*  47:    */     {
/*  48: 74 */       advance();
/*  49: 75 */       return true;
/*  50:    */     }
/*  51: 77 */     return false;
/*  52:    */   }
/*  53:    */   
/*  54:    */   protected final void match(IElementType paramIElementType, String paramString)
/*  55:    */   {
/*  56: 81 */     if (!matches(paramIElementType))
/*  57:    */     {
/*  58: 82 */       error(paramString);
/*  59: 83 */       advance();
/*  60:    */     }
/*  61:    */   }
/*  62:    */   
/*  63:    */   protected final void match(TokenSet paramTokenSet, String paramString)
/*  64:    */   {
/*  65: 88 */     if (!matches(paramTokenSet))
/*  66:    */     {
/*  67: 89 */       error(paramString);
/*  68: 90 */       advance();
/*  69:    */     }
/*  70:    */   }
/*  71:    */   
/*  72:    */   protected final void error(String paramString)
/*  73:    */   {
/*  74: 95 */     this.myBuilder.error(paramString);
/*  75:    */   }
/*  76:    */   
/*  77:    */   protected final void advance()
/*  78:    */   {
/*  79: 99 */     this.myBuilder.advanceLexer();
/*  80:    */   }
/*  81:    */   
/*  82:    */   protected final IElementType currentToken()
/*  83:    */   {
/*  84:103 */     IElementType localIElementType = this.myBuilder.getTokenType();
/*  85:    */     PsiBuilder.Marker localMarker;
/*  86:104 */     if (isName(localIElementType))
/*  87:    */     {
/*  88:105 */       localMarker = this.myBuilder.mark();
/*  89:106 */       makeName();
/*  90:107 */       if (this.myBuilder.getTokenType() == RncTokenTypes.LBRACKET)
/*  91:    */       {
/*  92:108 */         a(localMarker, RncElementTypes.ANNOTATION_ELEMENT);
/*  93:109 */         return currentToken();
/*  94:    */       }
/*  95:111 */       localMarker.rollbackTo();
/*  96:    */     }
/*  97:    */     else
/*  98:    */     {
/*  99:113 */       if (localIElementType == RncTokenTypes.LBRACKET)
/* 100:    */       {
/* 101:114 */         localMarker = this.myBuilder.mark();
/* 102:115 */         a(localMarker, RncElementTypes.ANNOTATION);
/* 103:116 */         return currentToken();
/* 104:    */       }
/* 105:117 */       if (localIElementType == RncTokenTypes.GTGT)
/* 106:    */       {
/* 107:118 */         localMarker = this.myBuilder.mark();
/* 108:119 */         advance();
/* 109:120 */         if (isName(this.myBuilder.getTokenType()))
/* 110:    */         {
/* 111:121 */           makeName();
/* 112:122 */           if (this.myBuilder.getTokenType() == RncTokenTypes.LBRACKET)
/* 113:    */           {
/* 114:123 */             a(localMarker, RncElementTypes.FORWARD_ANNOTATION);
/* 115:124 */             return currentToken();
/* 116:    */           }
/* 117:    */         }
/* 118:127 */         localMarker.done(RncElementTypes.FORWARD_ANNOTATION);
/* 119:128 */         return currentToken();
/* 120:    */       }
/* 121:    */     }
/* 122:130 */     return localIElementType;
/* 123:    */   }
/* 124:    */   
/* 125:    */   protected static boolean isName(IElementType paramIElementType)
/* 126:    */   {
/* 127:134 */     return (RncTokenTypes.IDENTIFIER_OR_KEYWORD.contains(paramIElementType)) || (paramIElementType == RncTokenTypes.PREFIXED_NAME);
/* 128:    */   }
/* 129:    */   
/* 130:    */   private void a(PsiBuilder.Marker paramMarker, IElementType paramIElementType)
/* 131:    */   {
/* 132:138 */     int i = this.myBuilder.getTokenType() == RncTokenTypes.LBRACKET ? 1 : 0;
/* 133:139 */     advance();
/* 134:140 */     assert (i != 0);
/* 135:142 */     while ((!this.myBuilder.eof()) && (currentToken() != RncTokenTypes.RBRACKET)) {
/* 136:143 */       advance();
/* 137:    */     }
/* 138:145 */     if (this.myBuilder.getTokenType() == RncTokenTypes.RBRACKET) {
/* 139:146 */       advance();
/* 140:    */     }
/* 141:148 */     paramMarker.done(paramIElementType);
/* 142:    */   }
/* 143:    */   
/* 144:    */   protected final void makeName()
/* 145:    */   {
/* 146:152 */     PsiBuilder.Marker localMarker = this.myBuilder.mark();
/* 147:153 */     advance();
/* 148:154 */     localMarker.done(RncElementTypes.NAME);
/* 149:    */   }
/* 150:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.plugins.relaxNG.compact.parser.AbstractParsing

 * JD-Core Version:    0.7.0.1

 */